from PySide2 import QtCore, QtGui, QtWidgets
import sys
from PySide2.QtWidgets import *


class Demo(QWidget):
    def __init__(self, parent=None):
        super(Demo, self).__init__(parent)
        self.initUI()

    def initUI(self):
        self.setWindowTitle("QQ登录窗口")
        grid = QGridLayout()
        label1 = QLabel()
        label1.setPixmap(QtGui.QPixmap('QQ3(1).jpg'))

        label2 = QLabel()
        label2.setPixmap(QtGui.QPixmap('QQ1.ico'))

        text1 = QLineEdit()

        label3 = QLabel()
        label3.setPixmap(QtGui.QPixmap('QQ2.ico'))

        text2 = QLineEdit()

        btn1 = QPushButton()
        btn1.setText("安全登录")

        # 在网格布局中添加各组件
        grid.addWidget(label1, 0, 0, 3, 4, QtCore.Qt.AlignCenter)
        grid.addWidget(label2, 3, 1, QtCore.Qt.AlignRight)
        grid.addWidget(text1, 3, 2, QtCore.Qt.AlignLeft)
        grid.addWidget(label3, 4, 1, QtCore.Qt.AlignRight)
        grid.addWidget(text2, 4, 2, QtCore.Qt.AlignLeft)
        grid.addWidget(btn1, 5, 1, 1, 2, QtCore.Qt.AlignCenter)

        self.setLayout(grid)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    demo = Demo()
    demo.show()
    sys.exit(app.exec_())
